package com.example.sss.service.ActorService;

import com.example.sss.dao.ActorMapper;
import com.example.sss.dao.UserMapper;
import com.example.sss.model.domin.Actor;
import com.example.sss.model.domin.User;
import com.example.sss.model.utils.ObsPage;
import com.example.sss.service.ObsService.ObsService;
import com.example.sss.service.UserService.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Transactional
@Service
public class ActorServiceImpl implements ActorService {
    /**
     * 依赖注入
     */
    @Autowired
    ActorMapper actorMapper;

    @Override
    public ObsPage selectActors(Actor actor) {
        PageHelper.startPage(actor.getCurPage(),actor.getPageSize());
        Page<Actor> actors =(Page<Actor>) actorMapper.selectActorsList(actor);
        return new ObsPage(actors.getTotal(),actors.getResult());
    }

    @Override
    public int addActor(Actor actor) {
        actor.setCreateTime(new Date());
        return actorMapper.addActor(actor);
    }

    @Override
    public int updateActor(Actor actor) {
        return actorMapper.updateActor(actor);
    }

    @Override
    public int deleteActor(Integer id) {
        return actorMapper.deleteActorById(id);
    }
}
